const quest = [{
		id: 1,
		title: "question1",
		type: 1,
		edit: false,
		ansVal: 'A',
		showTip: false,
		answer: [{
				id: 1,
				title: 'A. 1q',
				checked: 'true'
			}, {
				id: 2,
				title: 'B. 2q',
				checked: 'false'
			},
			{
				id: 3,
				title: 'C. 3q',
				checked: 'false'
			}, {
				id: 4,
				title: 'D. 4q',
				checked: 'false'
			}
		]
	},
	{
		id: 2,
		title: "question2",
		type: 3,
		edit: false,
		ansVal: 'A,D',
		showTip: false,
		answer: [{
				id: 1,
				title: 'A. 1q',
				checked: 'true'
			}, {
				id: 2,
				title: 'B. 2q',
				checked: 'false'
			},
			{
				id: 3,
				title: 'C. 3q',
				checked: 'true'
			}, {
				id: 4,
				title: 'D. 4q',
				checked: 'false'
			}
		]
	},
	{
		id: 3,
		title: "question3 blank",
		type: 2,
		edit: false,
		ansVal: '',
		showTip: false,
		answer: 'blank answer'
	},
	{
		id: 4,
		title: "question4 right or wrong",
		type: 4,
		edit: false,
		ansVal: 'R',
		showTip: false,
		answer: ''
	},
]

const ArrUtils = {
	addElementAfter(arr, index, newElement) {
		arr.splice(index + 1, 0, newElement);
		return arr;
	},
	removeElementAtIndex(arr, index) {
		if (index >= 0 && index < arr.length) {
			arr.splice(index, 1);
		}
		return arr;
	},
	moveElementForward(arr, element) {
		let index = arr.indexOf(element);
		if (index > 0) {
			let removedElement = arr.splice(index, 1)[0];
			arr.splice(index - 1, 0, removedElement);
		}
		return arr;
	},
	moveElementBackward(arr, element) {
		let index = arr.indexOf(element);
		if (index >= 0 && index < arr.length - 1) {
			let removedElement = arr.splice(index, 1)[0];
			arr.splice(index + 1, 0, removedElement);
		}
		return arr;
	},
	moveToFirst(arr, element) {
		const index = arr.indexOf(element);
		if (index > -1) {
			arr.splice(index, 1);
			arr.unshift(element);
		}
		return arr;
	},
	moveToLast(arr, element) {
		const index = arr.indexOf(element);
		if (index > -1) {
			arr.splice(index, 1);
			arr.push(element);
		}
		return arr;
	}
}


const types = [{
		id: 1,
		title: '单选'
	},
	{
		id: 3,
		title: '多选'
	},
	{
		id: 2,
		title: '填空'
	},
	{
		id: 4,
		title: '判断'
	}
]

export default {
	quest,
	types,
	ArrUtils
}